package redis;

import org.junit.Test;

import redis.clients.jedis.Jedis;

public class TestString {
	static Jedis jedis = null;

    static {
        jedis = new Jedis("192.168.79.131", 6379);//redis服务器地址与端口号
        jedis.auth("211125");    }
    
    // 测试Java做为客户端连接redis
    public static void main(String[] args) {
    	System.out.println("服务启动..."+jedis.ping());
    	jedis.flushDB();
    }
    
    // 7.5.3 操作字符串
    @Test
    public void getsetTest() {
    	String oldvalue = jedis.getSet("sclass", "ruanjian211");
    	System.out.println(oldvalue);
    }
    
    @Test
    public void strlenTest() {
    	Long valuelen = jedis.strlen("sclass");
    	System.out.println(valuelen);
    }
    
    @Test
    public void getrangeTest() {
    	String value = jedis.getrange("sclass", 3, 5);
    	System.out.println(value);
    }
    
    @Test
    public void appendTest() {
    	Long len = jedis.append("sclass1","0000");
    	System.out.println(len);
    }
    
}
